package com.jtny.nytb.equipment.dao.araetype;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jtny.component.core.mapper.CoreMapper;
import com.jtny.nytb.equipment.domain.areatype.DeviceAreaDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author 智慧能源中心 - xqx
 * @package com.jtny.energymonitor.equipment.dao
 * @fileName DeviceAreaDAO.java
 * @createTime 2023年09月15日 14:04
 * @Copyright© 2023 jtny
 * 江投能源技术研究院 版权所有
 */
@Mapper
public interface DeviceAreaDAO extends BaseMapper<DeviceAreaDO> {
    @Select("SELECT MAX(code) FROM em_equipment_area WHERE LENGTH(code) = #{length}")
    String getMaxCodeForLevel(@Param("length") int length);

    @Select("SELECT MAX(code) FROM em_equipment_area WHERE code LIKE CONCAT(#{parentCode}, '%')")
    String getMaxCodeForParent(@Param("parentCode") String parentCode);
}
